
using DslFactory.Utilities.DteCodeModel;
using EnvDTE;
namespace Dslfactory.wcfLanguage
{
 public partial class DataClassUsesDataClasses
 {
  internal string GetRoleNameValue()
  {
   if (RepresentedDataMember != null)
    return RepresentedDataMember.Name;
   else
    return string.Empty;
  }

  internal void SetRoleNameValue(string roleName)
  {
   if (RepresentedDataMember != null)
    RepresentedDataMember.Name = roleName;
  }

  internal string GetCardinalityValue()
  {
   if (RepresentedDataMember != null)
   {
    Project project = StoreCorrespondance.GetProjectForStore(Store);
    if (project == null)
     return "1";
    CodeModel codeModel = project.CodeModel;
    if (codeModel == null)
     return "1";
    CodeTypeRef codeType = codeModel.CreateCodeTypeRef(RepresentedDataMember.MemberFullTypeName);
    if (codeType == null)
     return "1";
    if (codeType.TypeKind == vsCMTypeRef.vsCMTypeRefArray)
     return "*";
    else
     return "1";
   }
   else
    return "1";
  }


  internal string GetTypeValue()
  {
   if (RepresentedDataMember != null)
   {
    return RepresentedDataMember.MemberFullTypeName;
   }
   else
    return string.Empty;
  }


  internal DataMemberKind GetKindValue()
  {
   if (RepresentedDataMember != null)
    return RepresentedDataMember.Kind;
   else
    return DataMemberKind.Field;
  }

  internal void SetKindValue(DataMemberKind value)
  {
   if (RepresentedDataMember != null)
     RepresentedDataMember.Kind = value;
  }


 }
}
